<?php
/**
 * Created by PhpStorm.
 * User: Q1369
 * Date: 2019/9/6
 * Time: 19:51
 */

namespace app\model;


use think\Model;

class User extends  Model
{
    /**
     * 添加用户
     * @param string $username
     * @param string $password
     * @return int|string
     */
    public  function add($username='', $password=''){
         $data['mobile'] = $username;
         $data['password'] =md5($password) ;
        return $this->insert($data);
    }

    /**
     * 校验用户名密码
     * @param string $username
     * @param string $password
     * @return bool
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function checkPassword($username='', $password=''){
        $id = $this->where('mobile',$username)->where('password',$password)->value('id');
        return $id??0;

    }

}